package gemini.pollux.ui.client.mvp.event;

import gemini.pollux.ui.client.utils.UIConstants.LayoutPosition;
import ch.elca.gwt.mvp.client.place.PlaceRequest;

import com.google.gwt.event.shared.GwtEvent;

public class ContainerRequestEvent extends GwtEvent<ContainerRequestHandler> {

	    private static Type<ContainerRequestHandler> TYPE;

	    public static Type<ContainerRequestHandler> getType() {
	        if ( TYPE == null )
	            TYPE = new Type<ContainerRequestHandler>();
	        return TYPE;
	    }

	    private final PlaceRequest request;
	    private boolean resetCurrentForm = true;
	    private Object object = null;
	    private LayoutPosition position;

	    public ContainerRequestEvent( PlaceRequest request) {
	        this.request = request;
	    }
	    
	    public ContainerRequestEvent( PlaceRequest request, LayoutPosition _p) {
	    	this.request = request;
	    	this.position = _p;
	    }

	    public ContainerRequestEvent( PlaceRequest request, Object object ) {
	        this.request = request;
	        this.object = object;
	    }

	    public ContainerRequestEvent( PlaceRequest request, boolean resetCurrentForm ) {
	        this.request = request;
	        this.resetCurrentForm = resetCurrentForm;
	    }

	    @Override
	    protected void dispatch(ContainerRequestHandler handler ) {
	        handler.onRequest( this );
	    }

	    @Override
	    public Type<ContainerRequestHandler> getAssociatedType() {
	        return getType();
	    }

	    public PlaceRequest getRequest() {
	        return request;
	    }

	    public Object getObject() {
	    	return object;
	    }

		public boolean isResetCurrentForm() {
			return resetCurrentForm;
		}

		public LayoutPosition getPosition() {
			return position;
		}
	}

